#{extends 'CRUD/layout.html' /}
#{set title:messages.get('crud.blank.title', type.modelName) /}

<div id="crudBlank" class="${type.name}">

    <h2 id="crudBlankTitle">&{'crud.blank.title', type.modelName}</h2>
	<div class="lastUpdate">(&{'entidad.lastUpdate'} ${object.getActualizado()} - ${object.lastLogs.descripcion})</div>
    <div class="objectForm">
     #{form action:@save(object._key()), enctype:'multipart/form-data'}
       #{if empresas!=null}
       <br>
       		<h2 id="crudShowTitle">Empresas</h2>
			<div class="empresas">
				<table>		
					<thead>
						<tr>
							<th>Razon Social</th>
							<th>Cargo</th>
							<th>Area</th>
							<th>Email</th>
							<th>Telefono</th>							
						</tr>
					</thead>
					#{list items:empresas, as:'contactoEmpresa'}				
						<tr>
							<td>${contactoEmpresa.organizacion}</td>
							<td>${contactoEmpresa.cargo}</td>
							<td>${contactoEmpresa.area}</td>
							<td>${contactoEmpresa.contacto.mail}</td>
							<td>${contactoEmpresa.contacto.telefono}</td>
						</tr>
					#{/list}
				</table>	
			</div>
       	<br>
       #{/if}
       	<div class="foto"><img src="@{attachment(object.id,'foto')}" style="border-width:0px;"></div>
       
       #{crud.form }
	    	 #{crud.custom 'localidad'}
	    	  	#{customs.customFieldLocalidad 
	    	  		selected:object.localidad, localidades:localidades, 
	    	  		provinciaSelected: provinciaSelected, provincias: provincias,
	    	  		paisSelected:paisSelected, paises: paises, 
	    	  		field:object /}
	    	 #{/crud.custom}
	    	 #{crud.custom 'origenDato'}
	    	  	#{customs.customFieldOrigenDato 
	    	  		selected:object.origenDato, 
	    	  		origenDatos: origenDatos,
	    	  		field:object /}
	    	 #{/crud.custom}
	    	 #{crud.custom 'sector'}
	    	  	#{customs.customFieldSector 
	    	  		selected:object.subrubro, subrubros:subrubros, 
	    	  		sectorSelected: sectorSelected, sectores: sectores,
	    	  		ramaSelected: ramaSelected, ramas: ramas,
	    	  		rubroSelected:rubroSelected, rubros: rubros, 
	    	  		field:object /}
	    	 #{/crud.custom}	
	    	 #{crud.custom 'rama'}
	    	  	#{customs.customFieldRama 
	    	  		selected:object.subrubro, subrubros:subrubros, 
	    	  		sectorSelected: sectorSelected, sectores: sectores,
	    	  		ramaSelected: ramaSelected, ramas: ramas,
	    	  		rubroSelected:rubroSelected, rubros: rubros, 
	    	  		field:object /}
	    	 #{/crud.custom}	
	    	 #{crud.custom 'rubro'}
	    	  	#{customs.customFieldRubro 
	    	  		selected:object.subrubro, subrubros:subrubros, 
	    	  		sectorSelected: sectorSelected, sectores: sectores,
	    	  		ramaSelected: ramaSelected, ramas: ramas,
	    	  		rubroSelected:rubroSelected, rubros: rubros, 
	    	  		field:object /}
	    	 #{/crud.custom}	
	    	 #{crud.custom 'subrubro'}
	    	  	#{customs.customFieldSubrubro 
	    	  		selected:object.subrubro, subrubros:subrubros, 
	    	  		sectorSelected: sectorSelected, sectores: sectores,
	    	  		ramaSelected: ramaSelected, ramas: ramas,
	    	  		rubroSelected:rubroSelected, rubros: rubros, 
	    	  		field:object /}
	    	 #{/crud.custom}
	    	 #{crud.custom 'arcadianos'}
	    	  	#{customs.customOrganizacionFieldArcadiano
	    	  		arcadianosOrganizacion: arcadianosOrganizacion, 
	    	  		arcadianos: arcadianos,
	    	  		lastArcadiano: lastArcadiano,
	    	  		organizacion:object._key() /}
	    	 #{/crud.custom} 	
	    	 #{crud.custom 'intermediario'}
	    	  	#{customs.customOrganizacionIntermediario 
	    	  		selected:object.intermediario, 
	    	  		intermediarios: intermediarios,
	    	  		field:object /}
	    	 #{/crud.custom}
	    	 
        #{/crud.form}
        #{if !object.persona.toString().equals("FISICA")}
        	#{customs.customFieldContacto contactosEmpresa: contactosEmpresa, contactos: contactos, organizacion:object._key()/} 
        #{/if}     
        <p class="crudButtons">
            <input type="submit" name="_save" value="&{'crud.save', type.modelName}" />
        </p>
    #{/form}
    </div>

</div>

<script type="text/javascript">
$().ready(function() {
	habilitarDatos();
	
	
})

function habilitarDatos(){		
		if($('#object_persona').val()=='IDEAL'){
			$('#object_tratamiento').parent().hide();
			$('#object_nombre').parent().hide();
			$('#object_apellido').parent().hide();
			$('#object_pareja').parent().hide();
			$('#object_razonSocial').parent().show();
		} else {
			$('#object_tratamiento').parent().show();
			$('#object_nombre').parent().show();
			$('#object_apellido').parent().show();
			$('#object_pareja').parent().show();
			$('#object_razonSocial').parent().hide();
		}
	}
</script>